﻿@{
    Layout = "~/Views/Shared/_Index.cshtml";
}

<div class="container-div">
    <div>
        <div class="btn-group-sm toolbar" id="toolbar1">
            <a id="btnAdd" class="btn btn-success"><i class="fa fa-plus"></i> 新增</a>
            <a id="btnEdit" class="btn btn-primary disabled"><i class="fa fa-edit"></i> 修改</a>
            <a id="btnDelete" class="btn btn-danger disabled"><i class="fa fa-remove"></i> 删除</a>
        </div>
        <div class="col-sm-12 select-table table-bordered">
            <table id="gridTable1" data-mobile-responsive="true"></table>
        </div>
    </div>

    <div>
        <div class="btn-group-sm toolbar" id="toolbar2">
            <a id="btnImport" class="btn btn-success"><i class="fa fa-upload"></i> 导入</a>
            <a id="btnExport" class="btn btn-primary disabled"><i class="fa fa-download"></i> 导出</a>
        </div>
        <div class="col-sm-12 select-table table-bordered">
            <table id="gridTable2" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        initGrid();
    });

    function initGrid() {
        var queryUrl = '@Url.Content("~/DemoManage/Table/GetPageListJson")';
        $('#gridTable1').ysTable({
            url: queryUrl,
            toolbar: '#toolbar1',
            pageSize: 3,
            columns: [
                [
                    { checkbox: true },
                    { field: 'Id', title: '用户ID' },
                    { field: 'RealName', title: '用户姓名' },
                    { field: 'Mobile', title: '用户手机' },
                    { field: 'Email', title: '邮箱' },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function (value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs" href="#"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs" href="#"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        }
                    }
                ]
            ],
            queryParams: function (params) {
                var pagination = $('#gridTable').ysTable('getPagination', params);
                var queryString = $('#searchDiv').getWebControls(pagination);
                return queryString;
            }
        });

        $('#gridTable2').ysTable({
            url: queryUrl,
            toolbar: '#toolbar2',
            pageSize: 5,
            columns: [
                [
                    { checkbox: true },
                    { field: 'Id', title: '用户ID' },
                    { field: 'RealName', title: '用户姓名' },
                    { field: 'Mobile', title: '用户手机' },
                    { field: 'Email', title: '邮箱' },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function (value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs" href="#"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs" href="#"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        }
                    }
                ]
            ],
            queryParams: function (params) {
                var pagination = $('#gridTable').ysTable('getPagination', params);
                var queryString = $('#searchDiv').getWebControls(pagination);
                return queryString;
            }
        });
    }
</script>
